#include "mystdio.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#define MYFILE "log.txt"

int main(){
  MY_FILE *fp = my_fopen(MYFILE,"w");
  if(fp == NULL){
    exit(-1);
  }

  const char *str = "|wwwwwwwww|";
  int cnt = 0;
  while(cnt < 10){
    char buffer[1024];
    snprintf(buffer, sizeof(buffer), "%s:%d\n", str, cnt++);
    size_t size = my_fwrite(buffer, strlen(buffer), 1, fp);
    sleep(1);
    printf("当前成功写入: %lu 个字节\n", size);
  }

  my_fclose(fp);

  return 0;

}
